<html>
<head>
	<link type="text/css" rel="stylesheet" href="../css/default.css" />
    <link type="text/css" rel="stylesheet" href="../js/rainbow/themes/sunburst.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
	<div class="page">
<h2>IgePathFinder <span>CLASS</span></h2>
<p>Declared in <a href="../../engine/core/IgePathFinder.js">IgePathFinder.js</a></p>
<div class="itemBox">
	<div class="header">Description</div>
	<div class="content">Creates a new path using the A* path-finding algorithm.</div>
</div>
<!--=if{extends}[-->
<div class="itemBox">
	<div class="header">Extends</div>
	<div class="content"><a href="IgeEventingClass.html">IgeEventingClass</a></div>
</div>
<!--=if{extends}]-->
<h2>Methods</h2><a name="squareCost"></a>
<h3 class="methodTitle">squareCost</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">Gets / sets the cost of movement over a square (left, right, up, down) adjacent tile.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">squareCost</span>({<span class="argType">Number</span>} <span class="argName">val</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType">Number</span>}<span class="argName">val</span> </li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">*</span>} </div>
    
</div><a name="diagonalCost"></a>
<h3 class="methodTitle">diagonalCost</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">Gets / sets the cost of movement over a diagonal (nw, ne, sw, se) adjacent tile.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">diagonalCost</span>({<span class="argType">Number</span>} <span class="argName">val</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType">Number</span>}<span class="argName">val</span> </li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">*</span>} </div>
    
</div><a name="neighbourLimit"></a>
<h3 class="methodTitle">neighbourLimit</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">Gets / sets the limit on the number of neighbour nodes that the path-finder will analyse before reaching it's target tile. On large maps this limit should be increased to allow pathing where many neighbours need to be considered.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">neighbourLimit</span>({<span class="argType"></span>} <span class="argName">val</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType"></span>}<span class="argName">val</span> </li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">*</span>} </div>
    
</div><a name="aStar"></a>
<h3 class="methodTitle">aStar</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">Uses the A* algorithm to generate path data between two points.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">aStar</span>({<span class="argType"><a href="./IgeCollisionMap2d.html">IgeCollisionMap2d</a></span>} <span class="argName">tileMap</span>, {<span class="argType"><a href="./IgePoint.html">IgePoint</a></span>} <span class="argName">startPoint</span>, {<span class="argType"><a href="./IgePoint.html">IgePoint</a></span>} <span class="argName">endPoint</span>, {<span class="argType">Function</span>} <span class="argName">comparisonCallback</span>, {<span class="argType">Boolean</span>} <span class="argName">allowSquare</span>, {<span class="argType">Boolean</span>} <span class="argName">allowDiagonal</span>, {<span class="argType">Boolean</span>} <span class="argName">allowInvalidDestination</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType"><a href="./IgeCollisionMap2d.html">IgeCollisionMap2d</a></span>}<span class="argName">tileMap</span> The tile map to use when generating the path.</li><li>{<span class="argType"><a href="./IgePoint.html">IgePoint</a></span>}<span class="argName">startPoint</span> The point on the map to start path-finding from.</li><li>{<span class="argType"><a href="./IgePoint.html">IgePoint</a></span>}<span class="argName">endPoint</span> The point on the map to try to path-find to.</li><li>{<span class="argType">Function</span>}<span class="argName">comparisonCallback</span> The callback function that will decide if each tile that is being considered for use in the path is allowed or not based on the tile map's data stored for that tile which is passed to this method as the first parameter. Must return a boolean value.</li><li>{<span class="argType">Boolean</span>}<span class="argName">allowSquare</span> Whether to allow neighboring tiles along a square axis. Defaults to true if undefined.</li><li>{<span class="argType">Boolean</span>}<span class="argName">allowDiagonal</span> Whether to allow neighboring tiles along a diagonal axis. Defaults to false if undefined.</li><li>{<span class="argType">Boolean</span>}<span class="argName">allowInvalidDestination</span> If the path finder cannot path to the destination tile, if this is true the closest path will be returned instead.</li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">Array</span>} An array of objects each containing an x, y co-ordinate that describes the path from the starting point to the end point in order.</div>
    
</div><a name="_getNeighbours"></a>
<h3 class="methodTitle">_getNeighbours</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">Get all the neighbors of a node for the A* algorithm.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">_getNeighbours</span>({<span class="argType"><a href="./IgePathNode.html">IgePathNode</a></span>} <span class="argName">currentNode</span>, {<span class="argType"><a href="./IgePathNode.html">IgePathNode</a></span>} <span class="argName">endPoint</span>, {<span class="argType"><a href="./IgeCollisionMap2d.html">IgeCollisionMap2d</a></span>} <span class="argName">tileMap</span>, {<span class="argType">Function</span>} <span class="argName">comparisonCallback</span>, {<span class="argType">Boolean</span>} <span class="argName">allowSquare</span>, {<span class="argType">Boolean</span>} <span class="argName">allowDiagonal</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType"><a href="./IgePathNode.html">IgePathNode</a></span>}<span class="argName">currentNode</span> The current node along the path to evaluate neighbors for.</li><li>{<span class="argType"><a href="./IgePathNode.html">IgePathNode</a></span>}<span class="argName">endPoint</span> The end point of the path.</li><li>{<span class="argType"><a href="./IgeCollisionMap2d.html">IgeCollisionMap2d</a></span>}<span class="argName">tileMap</span> The tile map to use when evaluating neighbours.</li><li>{<span class="argType">Function</span>}<span class="argName">comparisonCallback</span> The callback function that will decide if the tile data at the neighbouring node is to be used or not. Must return a boolean value.</li><li>{<span class="argType">Boolean</span>}<span class="argName">allowSquare</span> Whether to allow neighboring tiles along a square axis.</li><li>{<span class="argType">Boolean</span>}<span class="argName">allowDiagonal</span> Whether to allow neighboring tiles along a diagonal axis.</li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">Array</span>} An array containing nodes describing the neighbouring tiles of the current node.</div>
    
</div><a name="_heuristic"></a>
<h3 class="methodTitle">_heuristic</h3>
<div class="methodSection">
    <!--=if{desc}[-->
    <div class="methodDesc">The heuristic to calculate the rough cost of pathing from the x1, y1 to x2, y2.</div>
    <!--=if{desc}]-->
    <div class="methodDefinition"><span class="methodName">_heuristic</span>({<span class="argType">Number</span>} <span class="argName">x1</span>, {<span class="argType">Number</span>} <span class="argName">y1</span>, {<span class="argType">Number</span>} <span class="argName">x2</span>, {<span class="argType">Number</span>} <span class="argName">y2</span>)</div>
    <div class="methodArgs"><ul class="argList"><li>{<span class="argType">Number</span>}<span class="argName">x1</span> The first x co-ordinate.</li><li>{<span class="argType">Number</span>}<span class="argName">y1</span> The first y co-ordinate.</li><li>{<span class="argType">Number</span>}<span class="argName">x2</span> The second x co-ordinate.</li><li>{<span class="argType">Number</span>}<span class="argName">y2</span> The second y co-ordinate.</li></ul></div>
    <div class="methodReturnDesc">Returns {<span class="argType">Number</span>} Returns the heuristic cost between the co-ordinates specified.</div>
    
</div>	</div>
    <script type="text/javascript">
        $(function () {
            $('code').attr('data-language', 'javascript');
        });
    </script>
    <script type="text/javascript" src="../js/rainbow/rainbow-custom.min.js"></script>
</body>
</html>